<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>set_email</title>
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/fy/set_email.css">
</head>

<body>
    <div class="wrap">

        <!-- 头 -->
        <div class="parcel">
            <header>
                <div class="concent">
                    <div class="logo">
                        <a class="sub_log" href="/">胶囊日记</a>
                    </div>
                    <ul class="nav">
                        <li>
                            <a href="../ys/index.html">首页</a>
                        </li>
                        <li>
                            <a href="../zy/guanzhugeren1.html">关注</a>
                        </li>
                        <li>
                            <a href="/">话题</a>
                        </li>
                        <li>
                            <a href="/"><span>App</span>下载</a>
                        </li>
                    </ul>
                </div>

                <div class="sub_nav">

                    <div class="see write">
                        <a class="writeDiary" href="./text _diary.html">写日记</a>
                        <div class="color"></div>
                    </div>

                    <div class="set alert">
                        <a href="/">提醒(0)<span>▼</span></a>
                        <div class="alert_matter">
                            <div class="matter"></div>
                            <div class="sub_matter">
                                <span>没有提醒</span>
                            </div>
                        </div>

                    </div>


                    <div class="set auto">
                        <div class="userName">
                            <span class="mingzi"></span>
                            ▼
                        </div>


                        <div class="auto_sort">
                            <div class="sort"></div>
                            <div class="sub_sort">
                                <a href="/">我的日记</a>
                                <a href="/">我关注的人</a>
                                <a href="../../html/fy/set_message.html">设置</a>
                                <a href="/">退出</a>
                            </div>
                        </div>
                    </div>

                </div>


            </header>
        </div>
        <div class="top"></div>

        <!-- 主体 -->
        <div class="main">
            <!-- 个人信息 导航 -->
            <ul class="message">
                <li>
                    修改邮箱
                </li>
            </ul>

            <!-- 内容更改 -->
            <div class="sub_message">
                <div class="old">
                    <span class="old_password">密码:</span>
                    <input type="password" class="password">
                </div>

                <div class="new">
                    <span class="new_password">新邮箱:</span>
                    <input type="text" class="new_email">
                </div>

                <div class="password">
                    <span class="sub_password">再次输入新邮箱:</span>
                    <input type="text" class="email">
                </div>
                <button class="save">修改</button>
                <!-- <a class="save" href="./set-account.html">修改</a> -->
                <a class="write_off" href="./set-account.html">取消</a>
            </div>
        </div>

        <!-- 底 -->
        <div class="sole">
            <footer>
                <ul class="about_us">
                    <li>
                        <p>© 2009－2022</p>
                        <a class="timep" href="/">timepill.net</a>
                        <span>|</span>
                    </li>
                    <li>
                        <a href="/">沪ICP备18006482号-1</a>
                        <span>|</span>
                    </li>
                    <li>
                        <a href="/">常见问题</a>
                        <span>|</span>
                    </li>
                    <li>
                        <a href="/">捐助胶囊</a>
                        <span>|</span>
                    </li>
                    <li>
                        <p class="about">联系我们:mx1700@gmail.com</p>
                    </li>
                </ul>


                <ul class="rendered">
                    <li>
                        <a href="/">图片存储由又拍云存储提供</a>
                        <span>|</span>
                    </li>
                    <li>
                        <p>rendered in 0.0034 s</p>
                    </li>
                </ul>
            </footer>

        </div>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="../../js/requestPre.js"></script>
<<<<<<< HEAD
<script src="../../js/fy/set_email.js"></script>
=======
<script>
    let passwordEl = document.querySelector('.password')
    let newEmailEl = document.querySelector('.new_email')
    let emailEl = document.querySelector('.email')

    let saveBth = document.querySelector('.save')

    saveBth.addEventListener('click', changePassword)
    async function changePassword(e) {

        let password = passwordEl.value.trim()
        let newEmail = newEmailEl.value.trim()
        let email = emailEl.value.trim()

        let emailReg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

        // 都为空的时候
        if (!password || !newEmail || !email) {
            return alert('不能为空')
        }
        // // 新密码和确认密码不填时
        if (!emailReg.test(newEmail)) {
            return alert('请正确输入QQ邮箱')
        }
        if (newEmail != email) {
            alert('两次邮箱设置不一样')
        }

        // 发请求，添加数据
        let res = await axios({
            method: 'POST',
            url: '/api/user/revise/email',
            data: {

                "userId": "632197bd8c0fd333f646d17c",
                "password": "12345",
                "newemail": "12345@qq.com"

            }
        })
        console.log(res);


        let { code, msg, data } = res.data

        // 请求错误
        if (code) {
            return alert(msg)
        }
        // 存储当前用户的信息
        localStorage.user = JSON.stringify(data)
        // // 跳转页面至首页
        location.href = './set_message.html'

    }
</script>
>>>>>>> 096bacc8c8ec486a8690e4749be02e8a4d1777c8

</html>